package com.mazaiting.blog.dao

import com.mazaiting.blog.domain.Article
import org.junit.Test
import org.junit.runner.RunWith
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.junit4.SpringRunner
import java.sql.Timestamp
import javax.annotation.Resource

@RunWith(SpringRunner::class)
@EnableAutoConfiguration
@SpringBootTest
class ArticleDaoTest {

    @Resource
    private lateinit var articleDao: ArticleDao

    @Test
    fun selectCategoryByUID() {
        val list = articleDao.selectCategoryByUID(10)
        println(list)
    }

    @Test
    fun selectCategoryByName() {
        val category = articleDao.selectCategoryByNameAndUID("Android", 10)
        println(category)
    }

    @Test
    fun addCategory() {
        val id = articleDao.addCategory("Android", 3, Timestamp(System.currentTimeMillis()))
        println(id)
    }

    @Test
    fun addArticle() {
        val article = Article("AndroidTest", 10, 4, Timestamp(System.currentTimeMillis()))
        val id = articleDao.addArticle(article)
        println(id)
    }

    @Test
    fun selectArticleByNameAndId() {
        val map = articleDao.selectArticleByNameAndId("AndroidTest", 10, 4)
        println(map)
    }

    @Test
    fun selectArticleByUID() {
        val list = articleDao.selectArticleByUID(10, 4)
        println(list)
    }
}